﻿define(['models/model.pageconfig','model.mapper/model.mapper.pagesitemap','model.mapper/model.mapper.pagemenu','model.mapper/model.mapper.toplink',
'model.mapper/model.mapper.bottomlink','model.mapper/model.mapper.config'
			], function(PageConfigModel, pageSiteMapMapper, pageMenuMapper, topLinkMapper, bottomLinkMapper, configMapper) {
	var PageConig = {
		getDtoId : function(dto) {
			return dto.pageid;
		},
		fromDto : function(dto, item) {
			item = item || new PageConfigModel();
			item.pageId = dto.pageid;
			
			if(dto.toplinks){
				var topLinks = [];
				for (var i = 0; i < dto.toplinks.length; i ++ ){
					var topLink = topLinkMapper.fromDto(dto.toplinks[i]);
					topLinks.push(topLink);
				}
			}
			item.topLinks = topLinks ;
			
			var bottomLinks = [];
			for (var i = 0; i < dto.bottomlinks.length; i ++ ){
				var bottomLink = bottomLinkMapper.fromDto(dto.bottomlinks[i]);
				bottomLinks.push(bottomLink);
			}
			item.bottomLinks = bottomLinks;
			
			item.mooriConfigs = dto.mooriconfigs;
			
			var menus = [];
			for (var i = 0; i < dto.menus.length; i ++ ){
				var menu = pageMenuMapper.fromDto(dto.menus[i]);
				menus.push(menu);
			}
			item.menus = menus ;
			
			item.pagePath = dto.pagepath;
			item.pageTitle = dto.pagetitle ;
			return item;
		}
	};
	return PageConig;
}); 